<?php

/**
 * 默认控制器
 */
class Controller_Default extends Controller_Abstract
{
    function actionIndex()
    {
        // 为 $this->_view 指定的值将会传递数据到视图中
		# $this->_view['text'] = 'Hello!';
            $indexs = Article::find()->getAll();
            $page = intval($this->_context->page);
            if($page<1){
               $page=1;
            }
           
            $article = Article::find();
            $article->limitpage($page, 20);
            
            $this->_view['pagination'] = $article->getPagination();
            $this->_view['articles'] = $article->getAll();    
           $this->_view['indexs'] = $this->_view['articles'];
    }
    
    function actionView()
    {
        $index = Article::find()->getAll();
        $article = Article::find('id=?',$this->_context->id)->query();
        if(!$article->id){
            return $this->_redirectMessage('ERROR', 'view articile Error!!', url('default/index'));
        }
        $this->_view['article'] = $article;
        $this->_view['indexs'] = $index;
    }
}

